package 第1节循环语句;

public class LianXi01 {
    public static void main(String[] args) {
        System.out.println("模式A");
        for (int row = 1; row <= 6; row++) {
            for (int col = 1; col <= row; col++) {
                System.out.print(col + " ");
            }
            System.out.println();
        }
        System.out.println("模式B");
        for (int row = 6; row >= 1; row--) {
            for (int col = 1; col <= row; col++) {
                System.out.print(col + " ");
            }
            System.out.println();
        }
        System.out.println("模式C");
        /*
               row   k
          1     1    5
        2 1     2    4
      3 2 1     3    3
    4 3 2 1     4    2
  5 4 3 2 1     5    1
6 5 4 3 2 1     6    0
        */
        for (int row = 1; row <= 6; row++) {
            for (int k = 1; k <= 6 - row; k++) {
                System.out.print(" " + " ");
            }
            for (int col = row; col >= 1; col--) {
                System.out.print(col + " ");
            }
            System.out.println();
        }
        System.out.println("模式D");
        /*
                row     k
1 2 3 4 5 6     6       0
  1 2 3 4 5     5       1
    1 2 3 4     4       2
      1 2 3     3       3
        1 2     2       4
          1     1       5
        */
        for (int row = 6; row >=1; row--) {
            for (int k = 1; k <= 6 - row; k++) {
                System.out.print(" " + " ");
            }
            for (int col = 1; col <= row; col++) {
                System.out.print(col + " ");
            }
            System.out.println();
        }
    }
}
